package com.loren.demo27.controller;

import com.loren.demo27.form.validate.TestForm;
import com.loren.demo27.service.ValidateService;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@AllArgsConstructor
public class ValidateController {

    private final ValidateService validateService;

    @GetMapping("/test-01")
    public String test01(@Validated TestForm testForm) {
        return testForm.toString();
    }

    @PostMapping("/test-02")
    public String test02(@RequestBody @Validated TestForm testForm) {
        return testForm.toString();
    }

    @GetMapping("/test-03")
    public String test03(TestForm testForm) {
        return this.validateService.test(testForm);
    }

}
